var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function (req, res,) {
  // 客户端进入购物车
  let {username} = req.query;
  if (!username) {
    res.send({ err: 1, msg: '用户名为必传参数' })
    return;
  }
  //页面数据
  try {
    req.mgdb.findDetail({ collectionName: "cart", _q:username }).then((result) => {
      res.send(result);
    }).catch((err) => {
      res.send(err);
    })
  } catch (e) {
    res.send(e);
  }
});
router.use('/add', require('./cart/add'));
router.use('/update', require('./cart/update'));
router.use('/clear', require('./cart/clear'));
module.exports = router;
